Skip to main content

単一軸の動きの制御

を参照してください PLCopenSingle.project のインストールディレクトリにあるサンプルプロジェクト CODESYS..\CODESYS SoftMotion\Examples

この例は、PLCopenの標準化された機能ブロックを使用してドライブを制御する方法を示しています。

  1. 名前の付いた仮想ドライブを挿入します Drive 下のデバイスツリーで SoftMotion一般軸プール

  2. 作成する MOTION_PRG STのプログラム。

    PROGRAM MOTION_PRG
    VAR
            iStatus: INT;
            Power: MC_Power;
            MoveAbsolute: MC_MoveAbsolute;
            p:REAL:=100;
    END_VAR
    
    CASE iStatus OF
    
    // initialization of the axis
    0:
            Power(Enable:=TRUE, bRegulatorOn:=TRUE, bDriveStart:=TRUE, Axis:=Drive);
            IF Power.Status THEN
                    iStatus := iStatus + 1;
            END_IF
    
    // Move the axis to position p by use of the MC_MoveAbsolute function block
    1:
            MoveAbsolute(Execute:=TRUE, Position:= p, Velocity:=100, Acceleration:=100, Deceleration:=100, Axis:=Drive);
            IF MoveAbsolute.Done THEN
                    MoveAbsolute(Execute:=FALSE, Axis:=Drive);
                    iStatus := iStatus + 1;
            END_IF
    
    // Move the axis back to position 0 by use of the MC_MoveAbsolute function block:
    2:
            MoveAbsolute(Execute:=TRUE, Position:= 0, Velocity:=100, Acceleration:=100, Deceleration:=100, Axis:=Drive);
            IF MoveAbsolute.Done THEN
                    MoveAbsolute(Execute:=FALSE, Axis:=Drive);
                    iStatus := 1;
            END_IF
  3. MOTION_PRGプログラムの呼び出しをタスクに追加します 主な任務

    デバイスツリー:

    _sm_img_example_single_axis_2.png
  4. プロジェクトをコントローラーにダウンロードして開始します。

  5. を開きます ドライブ エディターの仮想軸。

    の中に オンライン の一部 全般的 タブ、あなたは軸の動きを見る。

    _sm_img_example_single_axis_1.png